
capture noisily mkdir  "${results}/othergraphs"
************************ HISTOGRAM***************************
********Figure 2a: Distribution of Birthdates*********
set scheme s1manual
global measure = "obs"
global m_obs = 2000

use "${results}/mainrd_graph", clear
keep if ages==23 & outcome=="wagez3" & samp=="k1elig"

summ ${measure}
local ymax = ceil(1.2*r(max)/${m_obs})*${m_obs}

twoway bar obs bin_z if inrange(bin_z0,-8,7) , color(gs11) barwidth(2) lwidth(thin) ///
	|| bar obs bin_z if  inrange(bin_z0,-30,30) & !inrange(bin_z0,-8,7), color(gs6) barwidth(2)  lwidth(thin)  ///
			xtitle("Birthdate (Centered at Jan 1)") ytitle("") ///
			yscale(range(0 `ymax')) xline(0,  lcolor(black) )  ///
			ylabel(#6, labsize(small) angle(0) )  xlabel(#7) legend(off)
graph export "${results}/othergraphs/f2_hist.pdf", replace


**************************Effect of Cash Transfer Eligibility on Family Resources Before and After Birth******************************
**Figures 6, A12, A13
use ${results}/final_tmech, clear
gen l_ci95 = b_bcut -1.96*se_bcut
gen u_ci95 = b_bcut +1.96*se_bcut

destring t, force gen(t0)

global ysc_parent_wagez = "yscale(range(-4000 4000)) ylabel(#6)"
global ysc_i_married0 = "yscale(range(-.04 .04)) ylabel(#6)"
global ysc_i_pov0 = "yscale(range(-.04 .04)) ylabel(#6)"
global ysc_parent_i_1040 = "yscale(range(-.04 .04)) ylabel(#6)"

foreach y in parent_wagez i_married0 i_married0 i_pov0 parent_i_1040 { //
	levelsof restrict if outcome=="`y'", local(ss)
	local ss = "all Lfilers"
	foreach s of local ss {
			graph twoway rcap u_ci95 l_ci95 t0 if outcome=="`y'" & restrict=="`s'" ,  mcolor(black)  ///
				  || scatter b_bcut t0 if  outcome=="`y'"  & restrict=="`s'"  , color(black) msize(*.6) msymbol(O) ///
				  yline(0, lcolor(black))  xlabel( , valuelabel) xline(0, lcolor(gs11) lpatter(-) )  ///
				  xtitle("Year Relative to Birth") ytitle("Estimate") legend(off) xlabel(#6)  ${ysc_`y'}
			graph export ${results}/othergraphs/fmech_`y'_`s'.pdf, replace as(pdf)
	}
}

**************************Results by Age******************************
use ${results}/final_f5, clear
append using ${results}/final_fa10
append using ${results}/final_fa11

gen l_ci95 = b_bcut -1.96*se_bcut
gen u_ci95 = b_bcut +1.96*se_bcut

destring ages, gen(ages0)
gen agerange = "23-25" if ages0==23
replace agerange = "26-28" if ages0==26
replace agerange = "29-31" if ages0==29
replace agerange = "32-34" if ages0==32
replace agerange = "35-37" if ages0==35
encode agerange, gen(agerange0)

replace agerange0 = agerange0-0.1 if taxyrcuts=="1980_1981" &  restrict=="all"
replace agerange0 = agerange0+0.1 if taxyrcuts=="1990_1991" &  restrict=="all"

replace agerange0 = agerange0-0.1 if restrict=="male"
replace agerange0 = agerange0+0.1 if restrict=="female"

********Figure 5: Effect of Cash Transfer Eligibility on Adult Earnings: By Age*********
set scheme s1color
local s = "all"
graph twoway rcap u_ci95 l_ci95 agerange0 if  restrict=="`s'" & taxyrcuts=="1979_1991" & inrange(ages0,23,32), color(black)  ///
		  || scatter b_bcut agerange0 if   restrict=="`s'" & taxyrcuts=="1979_1991" & inrange(ages0,23,32), color(black) ///
		  yline(0, lcolor(black)) xlabel( , valuelabel) yscale(range(-400 3200)) ylabel(#5)  ///
		  xtitle("Age Range") ytitle("RD Estimate") legend(off)
graph export "${results}/othergraphs/f5_age.pdf", replace

********Figure A10: Effect of Cash Transfer Eligibility on Adult Earnings: By Sex-Age*********
local s1 = "male"
local s2 = "female"
graph twoway rcap u_ci95 l_ci95 agerange0 if outcome=="`y'" & restrict=="`s1'" & taxyrcuts=="1979_1991" & inrange(ages0,23,32), color(green)  ///
		|| scatter b_bcut agerange0 if  outcome=="`y'"  & restrict=="`s1'" & taxyrcuts=="1979_1991" & inrange(ages0,23,32), color(green) ///
		///
		|| rcap u_ci95 l_ci95 agerange0 if outcome=="`y'" & restrict=="`s2'" & taxyrcuts=="1979_1991" & inrange(ages0,23,32), color(orange)  ///
		|| scatter b_bcut agerange0 if  outcome=="`y'"  & restrict=="`s2'" & taxyrcuts=="1979_1991" & inrange(ages0,23,32), color(orange) ///
		yline(0, lcolor(black)) xlabel( , valuelabel) yscale(range(-400 3200)) ylabel(#5)  ///
		xtitle("Age Range") ytitle("RD Estimate") legend( order(2 6) row(1) lab(2 "Male") lab(6 "Female") )
graph export "${results}/othergraphs/fa10_agesex.pdf", replace

********Figure A11: Effect of Cash Transfer Eligibility on Adult Earnings: By Cohort-Age*********
local s = "all"
	graph twoway rcap u_ci95 l_ci95 agerange0 ifrestrict=="`s'" & taxyrcuts=="1980_1981", color(navy)  ///
		  || scatter b_bcut agerange0 if   restrict=="`s'" & taxyrcuts=="1980_1981" , color(navy) ///
		  || rcap u_ci95 l_ci95 agerange0 if  restrict=="`s'" & taxyrcuts=="1985_1986", color(green)  ///
		  || scatter b_bcut agerange0  if  restrict=="`s'" & taxyrcuts=="1985_1986", color(green) ///
		  || rcap u_ci95 l_ci95 agerange0 if  restrict=="`s'" & taxyrcuts=="1990_1991", color(orange)  ///
		  || scatter b_bcut agerange0  if   restrict=="`s'" & taxyrcuts=="1990_1991", color(orange) ///
		  yline(0, lcolor(black)) xlabel( , valuelabel) yscale(range(-400 3200)) ylabel(#5) ///
		  xtitle("Age Range") ytitle("RD Estimate") legend( order(2 4 6) row(1) lab(2 "1981-1982") lab(4 "1986-1987") lab(6 "1991-1992"))
graph export "${results}/othergraphs/f11_agecohort.pdf", replace



**************************Robustness******************************
********Figure A5: Adult Earnings RD Estimates by Donut Size*********
use ${results}/final_fa5b, clear
append using  ${results}/final_fa5

destring donut, replace

gen l_ci95 = b_bcut -1.96*se_bcut
gen u_ci95 = b_bcut +1.96*se_bcut

set scheme s1manual
foreach a in 23 26 {
	local r = `"  ages=="`a'" & ( (dtype=="symm" & fullwindow=="28" &  donut>=9) | ((dtype=="symm" |dtype=="")& fullwindow=="" & donut<9) ) & donut<=14"'
	graph twoway rcap u_ci95 l_ci95 donut if `r', color(black)  ///
	|| scatter b_bcut donut  if  `r', color(black) ///
	yline(0, lcolor(black)) legend(off) ///
	xtitle("Donut Size") ytitle("Estimate") xlabels(#7)
	graph export ${results}/othergraphs/fa5_donuts_a`a'.pdf, replace
}

********Figure A6: Adult Earnings RD Estimates by Bandwidth*********
use ${results}/final_fa6, clear

destring wdays, replace

gen l_ci95 = b_bcut -1.96*se_bcut
gen u_ci95 = b_bcut +1.96*se_bcut

set scheme s1manual
foreach a in 23 26 {
	local r = `"  ages=="`a'" "'
	graph twoway rcap u_ci95 l_ci95 wdays if `r', color(black)  ///
	|| scatter b_bcut donut  if  `r', color(black) ///
	yline(0, lcolor(black)) legend(off) ///
	xtitle("Window Size") ytitle("Estimate") xlabels(#7)
	graph export ${results}/othergraphs/fa6_bws_a`a'.pdf, replace
}
